<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center Mydata_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd0_0'>
					<view class='flex flex-wrap align-center Mydata_fd0_0_c0'>
						<text class='fu-iconfont2  Mydata_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
							data-url="1">&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='Mydata_fd0_0_c1_c0'>{{$t('我的资料')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end Mydata_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout Mydata_flex_1">
				<view class='flex flex-direction flex-wrap align-stretch flex-sub Mydata_fd1_0'>
					<view class='flex flex-wrap align-center flex-sub Mydata_fd1_0_c0' v-if="group==1">

						<view class='flex  Mydata_fd1_0_c0_c0'></view>

						<text class='Mydata_fd1_0_c0_c1'>{{$t('基本信息')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c1'>
						<text class='Mydata_fd1_0_c1_c0'>{{$t('头像')}}</text>
						<benben-image-upload :path.sync="list.avatar" :img-id.sync="header_img" :is-cropping="true"
							:is-show-clean="false" class="upload position-relative personalData_fd1_0_c1_higd">
						
							<image class=" Mydata_fd1_0_c1_c1" mode="aspectFill"
								:src="list.avatar ? list.avatar : STATIC_URL+'LOGO.png'"></image>
						</benben-image-upload>
						<!-- <image class='Mydata_fd1_0_c1_c1' mode="aspectFill" :src='list.avatar'></image> -->
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0'>
						<text class='Mydata_fd1_0_c2_c0'>{{$t('姓名')}}</text>
						<text class='Mydata_fd1_0_c2_c1'>{{group==1?list.real_name:list.nickname}}</text>
					</view>
					<benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1701938799488" :label.sync='sex'
						:value.sync='xb' :options='sex_options' mode='selector' :mask-show='true' :timeout='true'
						:picker-height='88' default-type='value' :default-props='{"label":"name","value":"value"}'>
						<template #picker-header>
							<view class='flex flex-wrap align-center justify-between personalData_picker2_0_higd'>
								<text class='personalData_picker2_0_c0_higd'
									@tap="$refs.benbenWritePickerCodepicker2.cancel()">{{$t('取消')}}</text>
								<text class='personalData_picker2_0_c1_higd'>{{$t('选择性别')}}</text>
								<text class='personalData_picker2_0_c2_higd'
									@tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">{{$t('确认')}}</text>
							</view>
						</template>
					</benben-picker>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0' @tap.stop="pickerDiy1701938799488=true">
						<text class='Mydata_fd1_0_c2_c0'>{{$t('性别')}}</text>
						<view class="">
							{{sex}}
						</view>
						<!-- <view class='flex flex-wrap align-center' v-if="group==1">
							<text class='Mydata_fd1_0_c2_c1' v-if=" list.gender=='1'">{{$t('男')}}</text>
							<text class='Mydata_fd1_0_c2_c1' v-if=" list.gender=='2'">{{$t('女')}}</text>
							<text class='Mydata_fd1_0_c2_c1' v-if=" list.gender==0">{{$t('保密')}}</text>
						</view>
						<view class="" v-else>
							<text class='Mydata_fd1_0_c2_c1' >{{list.sex_name}}</text>
						</view> -->
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c4'>
						<text class='Mydata_fd1_0_c2_c0'>{{$t('年龄')}}</text>
						<!-- <text class='Mydata_fd1_0_c2_c1'>{{age}}</text> -->
						 <text class='Mydata_fd1_0_c2_c1'>{{list.age}}</text>
					</view>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch flex-sub Mydata_fd1_1'>
					<view class='flex flex-wrap align-center flex-sub Mydata_fd1_0_c0' v-if="group==1">

						<view class='flex  Mydata_fd1_0_c0_c0'></view>

						<text class='Mydata_fd1_0_c0_c1'>{{$t('基本信息')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0'>
						<text class='Mydata_fd1_0_c2_c0'>{{group==1?$t('学号'):'教职工号'}}</text>
						<text class='Mydata_fd1_0_c2_c1'>{{group==1?list.account:list.name}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0' v-if="group==2">
						<text class='Mydata_fd1_0_c2_c0'>部门</text>
						<text class='Mydata_fd1_0_c2_c1'>{{list.memberdept_name}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0' v-if="group==2 && list.mobile">
						<text class='Mydata_fd1_0_c2_c0'>手机号</text>
						<text class='Mydata_fd1_0_c2_c1'>{{list.mobile}}</text>
					</view>
					
					<!-- <view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0'>
						<text class='Mydata_fd1_0_c2_c0'>{{$t('院系')}}</text>
						<text class='Mydata_fd1_0_c2_c1'>{{list.yuanxi_name}}</text>
					</view> -->
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0' v-if="group==1">
						<text class='Mydata_fd1_0_c2_c0'>{{$t('班级')}}</text>
						<text class='Mydata_fd1_0_c2_c1'>{{list.baseclass_name}}</text>
					</view>
					<!-- <view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0' v-if="group==1">
						<text class='Mydata_fd1_0_c2_c0'>{{$t('专业')}}</text>
						<text class='Mydata_fd1_0_c2_c1'>{{list.zhuanye_name}}</text>
					</view> -->
					<view class='flex flex-wrap align-center justify-between flex-sub Mydata_fd1_0_c0' v-if="group==1">
						<text class='Mydata_fd1_0_c2_c0'>{{$t('学历层次')}}</text>
						<text class='Mydata_fd1_0_c2_c1'>{{list.degree_name}}</text>
					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->

			<view class="flex benben-position-layout flex flex-wrap align-center prepare_flex_4"
				:style="{height:(110+bottomSafeAreaRpx)+'rpx',paddingBottom:bottomSafeAreaRpx+'rpx', }">
				<button class='prepare_fd4_0' @tap.stop="submitsFunc">提交修改</button>
			</view>
		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				group:uni.getStorageSync('USER_GROUP'),
				"list": {
					"id": "",
					"nickname": "",
					"baseclass_name": "",
					"basemajor_name": "",
					"avatar": "",
					"real_name": "",
					"gender": "",
					"mobile": "",
					"birthday": "",
					"baseclass_grade": "",
					"political_landscape": "",
					"account": "",
					"basedept_name": "",
					"degree_name": ""
				},
				"age": "",
				"header_img": "",
				"pickerDiy1701938799488": false,
				"sex_options": [{
					"name": "男",
					"value": "1",
					"image": ""
				}, {
					"name": "女",
					"value": "2",
					"image": ""
				}],
				"sex": "",
				xb:''
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			this.getyo6f4cf3a2bf31Func()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//计算年龄
			calculateFunc() {


				let date = new Date().getTime()
				date = Math.floor(date / 1000)
				let ageInSeconds = date - this.list.birthday
				let ageInYears = ageInSeconds / (60 * 60 * 24 * 365);
				this.age = Math.floor(ageInYears);
				// console.log("坤坤今年=>", this.age)
			},
			//APP接口-我的画像-个人信息
			async getyo6f4cf3a2bf31Func() {
				//请求方法
				//数据验证

				let datalist = await this.$api.get(global.apiUrls.post66f4cf3a2bf31, {

				});

				if (datalist.data.code != 1) {
					this.$message.info(datalist.data.msg);
					return
				}
				let infolist = datalist.data;
				this.list = infolist.data
				this.header_img = this.list.avatar
				if(this.group==1){
					this.xb=this.list.gender
					if (this.list.gender == '1') {
						this.sex = '男';
					} else if (this.list.gender == '2') {
						this.sex = ' 女';
					}
				}else{
					this.xb=this.list.sex
					this.sex=this.list.sex_name
				}
				
				this.calculateFunc()
			},
			async submitsFunc() {
				//请求方法
				//数据验证
				let obj = {
					avatar: this.list.avatar,
					// nickname: this.user.nickname,
					sex: this.xb
				}
				console.log(obj)
				// return
				let urls=this.group==1?global.apiUrls.post5cb54af125f1c:host+'/api/v1/5cb54af125f1c'
				let data5cb54af125f1c = await this.$api.post(global.apiUrls.post689f0b4d7c90e, {
					avatar: this.list.avatar,
					// nickname: this.user.nickname,
					sex: this.xb//gender：性别，1-男，2-女
				});
				if (!data5cb54af125f1c) return
				if (data5cb54af125f1c.data.code != 1) {
					this.$message.info(data5cb54af125f1c.data.msg);
					return
				}
				let info5cb54af125f1c = data5cb54af125f1c.data;
				

				this.$message.info('修改成功');
				setTimeout(function() {
					uni.navigateBack()
				}, 800);
				
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.Mydata_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.Mydata_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 700;
		color: #333333;
		line-height: 50rpx;
	}

	.Mydata_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.Mydata_fd0_0_c0 {
		width: 120rpx;
	}

	.Mydata_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.Mydata_flex_1 {
		padding: 24rpx;
	}

	.Mydata_fd1_1 {
		background: #Fff;
		border-radius: 16rpx;
		background-size: 100% auto;
		padding: 024rpx 024rpx 0rpx 024rpx;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.Mydata_fd1_0_c4 {
		width: 100%;
		height: 200rpx;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.Mydata_fd1_0_c2_c1 {
		font-size: 32rpx;
		line-height: 45rpx;
		color: rgba(51, 51, 51, 1);
	}

	.Mydata_fd1_0_c2_c0 {
		font-size: 32rpx;
		line-height: 45rpx;
		color: rgba(102, 102, 102, 1);
		font-weight: 500;
	}

	.Mydata_fd1_0_c1_c1 {
		width: 88rpx;
		height: 88rpx;
		border-radius: 44rpx;
	}

	.Mydata_fd1_0_c1_c0 {
		font-size: 32rpx;
		line-height: 45rpx;
		color: rgba(102, 102, 102, 1);
	}

	.Mydata_fd1_0_c1 {
		border-bottom: 1px solid rgba(238, 238, 238, 1);
		width: 100%;
		height: 152rpx;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.Mydata_fd1_0_c0_c1 {
		font-size: 32rpx;
		line-height: 45rpx;
		color: rgba(51, 51, 51, 1);
		font-weight: 500;
	}

	.Mydata_fd1_0_c0_c0 {
		background: #125fff;
		width: 6rpx;
		height: 28rpx;
		margin: 0rpx 10rpx 0rpx 10rpx;
		transform: scaleX(0.5);
	}

	.Mydata_fd1_0_c0 {
		border-bottom: 1px solid rgba(238, 238, 238, 1);
		width: 100%;
		height: 200rpx;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.Mydata_fd1_0 {
		background: #Fff;
		border-radius: 16rpx;
		background-size: 100% auto;
		padding: 024rpx 024rpx 0rpx 024rpx;
	}
	.prepare_flex_4 {
		width: 750rpx;
		height: 110rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		left: 0rpx;
		border-radius: 0rpx;
		.prepare_fd4_0 {
			background: #4781f5;
			width: 100%;
			line-height: 110rpx;
			font-size: 32rpx;
			color: #fff;
			border-radius: 0rpx;
		}
	}
	.personalData_picker2_0_higd {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
		border-radius: 25rpx 25rpx 0rpx 0rpx;
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% auto !important;
	
		.personalData_picker2_0_c0_higd {
			font-size: 28rpx;
			color: var(--benbenFontColor2);
		}
	
		.personalData_picker2_0_c1_higd {
			font-size: 32rpx;
			color: var(--benbenFontColor1);
		}
	
		.personalData_picker2_0_c2_higd {
			color: #4781f5;
			font-size: 28rpx;
		}
	}
</style>